//user.js
var moment = require("moment");
module.exports = function(sequelize, DataTypes) {
  var model = sequelize.define(
    "emp_sign",
    {
      id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        allowNull: false,
        autoIncrement: true
      },
      emp_id: DataTypes.INTEGER,
      emp_name: DataTypes.STRING,
      sign_date: {
        type: DataTypes.DATEONLY,
        get() {
          return moment(this.getDataValue("sign_date")).format("YYYY-MM-DD")
        }
      },
      sign_one: {
        type: DataTypes.DATE,
        get() {
          return moment(this.getDataValue("sign_one")).format("YYYY-MM-DD HH:mm:ss");
        }
      },
      sign_two: {
        type: DataTypes.DATE,
        get() {
          return moment(this.getDataValue("sign_two")).format("YYYY-MM-DD HH:mm:ss");
        }
      },
      sign_three: {
        type: DataTypes.DATE,
        get() {
          return moment(this.getDataValue("sign_three")).format("YYYY-MM-DD HH:mm:ss");
        }
      },
      sign_four: {
        type: DataTypes.DATE,
        get() {
          return moment(this.getDataValue("sign_four")).format("YYYY-MM-DD HH:mm:ss");
        }
      }
    },
    {
      freezeTableName: true, // Model 对应的表名将与model名相同
      timestamps: false
    }
  );

  return model;
};
